function defineReactive(data, key, val) {
  if (arguments.length == 2) {
    val = data[key];
  }
  let child = observe(val);
  let dep = new Dep();
  Object.defineProperty(data, key, {
    get() {
      console.log("读取了属性", key);
      dep.depend();
      if (child) {
        child.dep.depend();
      }
      return val;
    },
    set(newVal) {
      console.log("设置了属性", key);
      if (val === newVal) return;
      val = newVal;
      dep.notify();
    },
  });
}
